const App = {
    mixins: [Save],//配置文件，路径/utils/mixins.js
    data() {
        return {
            category: [],
            personal: [],
            village: [],
            cityValue: [],
            cityValue1: [],
            city: [],
            city1: [],
            // cityValue: ["230000", "232700", "232723"],
        };
    },
    mounted() {
        this.getCategory();
        this.getCity();
        // this.changeCity(this.cityValue);
    },
    watch: {
        'dataForm.Village_Collective_SerialNumber'(val) {
            let str = this.dataForm.VillageNumber
            if (str.substring(0, 6)) {
                $.ajax({
                    headers: requestHeaders(),
                    url: `${mh}/clientOperation/getDistrictTree`,
                    type: "GET",
                    data: {
                        DistrictCode: str.substring(0, 6)
                    },
                    success: (data) => {
                        this.city1 = data[0].children;
                        this.cityValue1 = [str.substring(0, 9), str];
                        this.cityValue = [str.substring(0, 2) + '0000', str.substring(0, 4) + '00', str.substring(0, 6)]
                    },
                    complete: (XMLHttpRequest) => {
                        requestPretreatment(XMLHttpRequest);
                    },
                    dataType: "json",
                });
            }
        },
    },
    methods: {
        getCity() {
            // $.ajax({
            //     url: `${absolutepath()}api/Districtjl.json`,
            //     method: "get",
            //     success: (data) => {
            //         data.forEach(item => {
            //             item.children.forEach(ite => {
            //                 ite.children.forEach(it => {
            //                     it.children = undefined
            //                 })
            //             })
            //         })
            //         this.city = data;
            //         this.cityValue = ["230000", "232700", "232723"];
            //         changeCity(this.cityValue);
            //     }
            // });
            this.changeCity();
        },
        getCategory() {
            // $.ajax({
            //     headers: requestHeaders(),
            //     url: `${mh}/generalBusiness/generalQueryByTableName`,
            //     type: "POST",
            //     data: {
            //         Data: 'base_system_village',
            //         Condition: "TownNumber LIKE '232723%'",
            //     },
            //     success: (data) => {
            //         this.village = data; // 直接使用 this
            //     },
            //     complete: (XMLHttpRequest) => {
            //         requestPretreatment(XMLHttpRequest);
            //     },
            //     dataType: "json",
            // });
            // $.ajax({
            //     headers: requestHeaders(),
            //     url: `${mh}/generalBusiness/generalQueryByTableName`,
            //     type: "POST",
            //     data: {
            //         Data: 'personal_information',
            //         Condition: "Row_Status='0'",
            //     },
            //     success: (data) => {
            //         this.personal = data; // 直接使用 this
            //     },
            //     complete: (XMLHttpRequest) => {
            //         requestPretreatment(XMLHttpRequest);
            //     },
            //     dataType: "json",
            // });
        },
        changeCity1(val) {
            console.log(val);
            if (val.length > 0) {
                this.dataForm.VillageNumber = val[1];
            } else {
                this.dataForm.VillageNumber = '';
            }

        },


        changeCity(val) {

            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/permissionsTree/getDistrictTreeByPermissions`,
                type: "GET",
                data: {
                    DistrictCode: getCookie('village'),
                },
                success: (data) => {
                    this.city1 = data[0].children;
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });

        },
    },
};
const { createApp, ref } = Vue;
const app = createApp(App);
app.use(ElementPlus, { locale: zhCn });
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
app.component('yl-upload', ylUpload);
app.component('yl-text-editor', ylTextEditor);
const ElMessage = ElementPlus.ElMessage;
app.mount("#app");
